package com.sand.util;

import java.util.List;
import java.util.Map;

public class PageModel<T> {
/**
 *
 *分页模型
 * @author <achao1441470436@gmail.com>
 * @since 2021/7/30/030 14:09
 */
    private int pageNo;//查询页数
    private int pageSize;//查询条数
    private int pagecount;//总条数
    private int pagesum;//总页数

    private List<T> list;
    private Map<String,Object> map;

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPagecount() {
        return pagecount;
    }

    public void setPagecount(int pagecount) {
        this.pagecount = pagecount;
        this.pagesum=this.pagecount/this.pageSize;
        if((this.pagecount%this.pageSize)>0){
            this.pagesum++;
        }
    }

    public int getPagesum() {
        return pagesum;
    }

    public void setPagesum(int pagesum) {
        this.pagesum = pagesum;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public Map<String, Object> getMap() {
        return map;
    }

    public void setMap(Map<String, Object> map) {
        this.map = map;
    }

    public int pageFirst(){
        return 1;
    }

    public int pageEnd(){
        return this.pagesum;
    }

    public int pageUp(){
        return (this.pageNo-1)<=1?1:this.pageNo-1;
    }

    public int pageDown(){
        return (this.pageNo+1)>=this.pagesum?this.pagesum:this.pageNo+1;
    }
}
